package com.bafa.front.postlogon;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bafa.dbcache.LeagueCache;
import com.bafa.exceptions.ErrorException;
import com.bafa.objects.Match;
import com.bafa.objects.*;
import com.bafa.services.RetrieveServices;
import com.bafa.front.DaddyServlet;
import com.bafa.front.presentationbeans.MatchBean;
import com.bafa.front.presentationbeans.PlayerListBean;
import com.bafa.front.presentationbeans.TeamBean;
import com.bafa.front.presentationbeans.TeamMatchBean;
import com.bafa.front.utils.*;
public class DisplayAddResultServlet extends PostLogonServlet {

	@Override
	public void doPostLogonEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
		
			String matchId = request.getParameter("matchId");
			TeamBean team = FrontUtils.getLoggedOnTeam(request);
			MatchBean match = new MatchBean(RetrieveServices.getMatch(new Integer(matchId).intValue()));
			PlayerListBean players = new PlayerListBean(RetrieveServices.getTeam(""+team.getId()).getStats().scorers());
			
			request.setAttribute("MATCH",match);
			request.setAttribute("PLAYERS",players);
			PageBean pageBeanTemp = (PageBean)LeagueCache.getPages().get("addresult");
			pageBean = new PageBean(pageBeanTemp);
			String pageHeader = pageBean.getPageheader().replaceAll("<>","Add your score vs ");
			pageBean.setPageheader(pageHeader);
		
		
	}
	
	
}
